package com.gwd.task.repository;

import com.gwd.task.entity.TestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author zhiyongming
 * @date 2020/12/24 15:06
 */
@Repository
public interface TestRepository extends JpaRepository<TestEntity, Long>, JpaSpecificationExecutor<TestEntity> {
    @Modifying
    @Transactional
    @Query(value = "update TestEntity e set e.status=8 where e.tId in ?1")
    void batchPendingRest(List<Long> ids);

    List<TestEntity> findByDevPersonInAndStatusInAndTypeIn(List<Long> ids, List<Integer> status, List<Integer> type);

    @Query(value = "select u from TestEntity u where u.relateId=?1 and u.tId<>?2 and u.status<>?3")
    List<TestEntity> findByOther(Long relateId, Long tId, Integer status);
}
